//
//  MTMainTabBarViewController.m
//  MotorTravel
//
//  Created by zk on 16/9/12.
//  Copyright © 2016年 zk. All rights reserved.
//

#import "MTMainTabBarViewController.h"
//#import "UIColor+MTHex.h"

@interface MTMainTabBarViewController ()

@end

@implementation MTMainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self tabbarViewControllers];//创建tabbarViewControllers
    [self configBarStyle];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)tabbarViewControllers {
    UIStoryboard *topic = [UIStoryboard storyboardWithName:@"Topics" bundle:nil];
    UIViewController *topicViewController = [topic instantiateInitialViewController];
    
    UIStoryboard *interest = [UIStoryboard storyboardWithName:@"Interest" bundle:nil];
    UIViewController *interestViewController = [interest instantiateInitialViewController];
    
    UIStoryboard *main = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *noneViewController = [main instantiateInitialViewController];
    
    UIStoryboard *rank = [UIStoryboard storyboardWithName:@"Rank" bundle:nil];
    UIViewController *rankViewController = [rank instantiateInitialViewController];
    
    UIStoryboard *mine = [UIStoryboard storyboardWithName:@"Mine" bundle:nil];
    UIViewController *mineViewController = [mine instantiateInitialViewController];
    
    self.viewControllers = [NSArray arrayWithObjects:topicViewController, interestViewController, noneViewController, rankViewController,mineViewController, nil];
}

- (void)configBarStyle {
    UITabBarItem *topicsTabBarItem = [[UITabBarItem alloc] initWithTitle:@"选题"
                                                                   image:[UIImage imageNamed:@""]
                                                           selectedImage:[UIImage imageNamed:@""]];
    UITabBarItem *interestTabBarItem = [[UITabBarItem alloc] initWithTitle:@"兴趣"
                                                                     image:[UIImage imageNamed:@""]
                                                             selectedImage:[UIImage imageNamed:@""]];
    UITabBarItem *noneTabBarItem = [[UITabBarItem alloc] initWithTitle:@"添加"
                                                                 image:[UIImage imageNamed:@""]
                                                         selectedImage:[UIImage imageNamed:@""]];
    UITabBarItem *rankTabBarItem = [[UITabBarItem alloc] initWithTitle:@"排行"
                                                                 image:[UIImage imageNamed:@""]
                                                         selectedImage:[UIImage imageNamed:@""]];
    UITabBarItem *mineTabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的"
                                                                 image:[UIImage imageNamed:@""]
                                                         selectedImage:[UIImage imageNamed:@""]];
    
    NSArray *itemsArray = @[topicsTabBarItem, interestTabBarItem, noneTabBarItem, rankTabBarItem, mineTabBarItem];
    for (int i = 0; i < itemsArray.count; i++) {
        UIViewController *vc = self.viewControllers[i];
        UITabBarItem *item = [itemsArray objectAtIndex:i];
        [item setTag:i];
        vc.tabBarItem = item;
    }
    
    [self setSelectedIndex:0];
    [self.tabBar setTintColor:[UIColor whiteColor]];
    for (UIBarItem *item in self.tabBar.items) {
        [item setTitleTextAttributes:@{
                                       NSForegroundColorAttributeName:[UIColor colorForHex:@"D3CFCF"],
                                       NSFontAttributeName:[UIFont systemFontOfSize:12]
                                       }
                            forState:UIControlStateNormal];
        [item setTitleTextAttributes:@{
                                       NSForegroundColorAttributeName:[UIColor colorForHex:@"4B9BFF"],
                                       NSFontAttributeName:[UIFont systemFontOfSize:12]
                                       }
                            forState:UIControlStateSelected];
    }
    
    //中间+号
    CGFloat windowHeight = self.view.frame.size.height;
    CGFloat width = self.view.frame.size.width / 5;
    //按钮
    UIButton *addButton = [[UIButton alloc] initWithFrame:CGRectMake(width * 2 + 4, windowHeight - self.tabBar.frame.size.height + 2, width - 8, self.tabBar.frame.size.height - 4)];
    addButton.backgroundColor = [UIColor redColor];
    [addButton addTarget:self action:@selector(AddButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:addButton];
}

- (void)AddButton {
    
}

@end
